local cjson = require "cjson"
local utils = require "gcs.utils"
local io_popen = io.popen
local tb_insert = table.insert
local str_find = string.find
local str_sub = string.sub
local config_table = ngx.shared.gcs_config

local db_data = {}

local file_path = config_table:get("p_logfile")

local res = io_popen("ls -kl --time-style=long-iso /image_root /data/logs")
for line in res:lines() do 
  local check_res = str_sub(line,-3,-1)
  if check_res == "log" then
    local res_data = {}
    local  a = string.split(line," ")
    res_data.size = a[5]
    res_data.time = a[6] .. " " ..  a[7] 
    res_data.name = a[8]
    tb_insert(db_data,res_data)
  end
end

ngx.say(cjson.encode(db_data))



